<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/28 0028
 * Time: 上午 11:23
 */
namespace app\api\controller;
use app\admin\Model\Collect;
use app\admin\model\Goods as Goodsmodel;


class Goods extends Baseapi{
    /**
     * @param $id
     * @return \think\response\Jsonp
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 商品详情页面
     */
    public function getdetial($id,$user_id){
        $res=Goodsmodel::with('shop,goodsclassify')->find($id);
        $where['user_id']=$user_id;
        $where['goods_id']=$id;
        $where['type']=2;
        if($user_id){
            $result=Collect::get($where);
            if($result->id){
                $res['collect']=1;
            }else{
                $res['collect']=0;
            }
        }else{
            $res['collect']=0;
        }
        if($res){
            $info['info']=$res->toArray();
            $info['status']=1;
        }else{
            $info['info']='请传入正确的参数！';
        }
        return jsonp($info);
    }


}